-
Notifications
You must be signed in to change notification settings - Fork 14k
CStr docs: Fix CStr vs &CStr confusion #148826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The CStr docs used to say things about CStr that are only true for &CStr. Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the motivation, but I'm not convinced that it's a good idea to talk about &CStr only. While currently a &mut CStr isn't particularly useful, we might want to add methods for e.g. ASCII case conversion in the long term. Perhaps the documentation could be rephrased to refer to the actual dynamically-sized CStr type, much like the documentation for slices does?
library/core/src/ffi/c_str.rs
Outdated
| /// The `&CStr` type represents a borrowed C string. | ||
| /// | ||
| /// This type represents a borrowed reference to a nul-terminated | ||
| /// Type `&CStr` represents a reference to a borrowed nul-terminated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Type `&CStr` represents a reference to a borrowed nul-terminated | |
| /// The type `&CStr` represents a reference to a borrowed nul-terminated |
|
Great, that reads well, thank you. |
CStr docs: Fix CStr vs &CStr confusion The CStr documentation used to say things about CStr that are only true for &CStr. Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
CStr docs: Fix CStr vs &CStr confusion The CStr documentation used to say things about CStr that are only true for &CStr. Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
CStr docs: Fix CStr vs &CStr confusion The CStr documentation used to say things about CStr that are only true for &CStr. Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
Rollup of 14 pull requests Successful merges: - #146978 (Emit error when using path-segment keyword as cfg pred) - #148543 (Correctly link to associated trait items in reexports) - #148808 (Some resolve cleanups) - #148812 (coverage: Associate hole spans with expansion tree nodes ) - #148826 (CStr docs: Fix CStr vs &CStr confusion) - #148850 (Implement `Read::read_array`) - #148867 (Refactor `Box::take`) - #148870 (Remove unused LLVMModuleRef argument) - #148878 (error when ABI does not support guaranteed tail calls) - #148901 (Disable rustdoc-test-builder test partially for SGX target.) - #148902 (add missing s390x target feature to std detect test) - #148904 (waffle: stop watching codegen ssa) - #148906 (Expose fmt::Arguments::from_str as unstable.) - #148907 (add assembly test for infinite recursion with `become`) r? `@ghost` `@rustbot` modify labels: rollup
CStr docs: Fix CStr vs &CStr confusion The CStr documentation used to say things about CStr that are only true for &CStr. Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
CStr docs: Fix CStr vs &CStr confusion The CStr documentation used to say things about CStr that are only true for &CStr. Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
Rollup of 15 pull requests Successful merges: - #148543 (Correctly link to associated trait items in reexports) - #148808 (Some resolve cleanups) - #148812 (coverage: Associate hole spans with expansion tree nodes ) - #148826 (CStr docs: Fix CStr vs &CStr confusion) - #148850 (Implement `Read::read_array`) - #148867 (Refactor `Box::take`) - #148870 (Remove unused LLVMModuleRef argument) - #148878 (error when ABI does not support guaranteed tail calls) - #148901 (Disable rustdoc-test-builder test partially for SGX target.) - #148902 (add missing s390x target feature to std detect test) - #148904 (waffle: stop watching codegen ssa) - #148906 (Expose fmt::Arguments::from_str as unstable.) - #148907 (add assembly test for infinite recursion with `become`) - #148928 (Move & adjust some `!`-adjacent tests) - #148929 (ignore `build-rust-analyzer` even if it's a symlink) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #148826 - btj:cstr-docs, r=joboet CStr docs: Fix CStr vs &CStr confusion The CStr documentation used to say things about CStr that are only true for &CStr. Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
The CStr documentation used to say things about CStr that are only true for &CStr.
Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.